// miniprogram/pages/freeLearn1/freeLearn1.js
var httpUtils = require('../../utils/httpUtils')
var api = require("../../utils/API")
var commonFields = require('../../utils/commonFields')
var utils = require('../../utils/utils')
Page({

  /**
   * 页面的初始数据
   */
  data: {
    subject: 1, //开始答题时间
    score: 0,
    correct: 0,
    wrong: 0,
    examMinute: 0,
    wxName: '',
    avatarUrl: '',
    unAnswer: 0,
    passSrc: '../../images/pass.png'
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    console.log(options)
    this.setData({
      subject: options.subject,
      score: options.score,
      correct: options.correct,
      wrong: options.wrong,
      examMinute: options.examMinute,
      unAnswer: options.subject == 1 ? 100 - options.correct - options.wrong : 50 - options.correct - options.wrong,
      avatarUrl: utils.getStorageSync(commonFields.userInfo).wxHeadImg,
      wxName: utils.getStorageSync(commonFields.userInfo).wxName,
      passSrc: options.score > 89 ? '../../images/pass.png' : '../../images/noPass.png'

    });




  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {

  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {

  },
  reviewTest() {
    wx.navigateBack({
      delta: 1
    })
  },
  reTest() {
    var subject = this.data.subject
    wx.navigateTo({
      url: api.PAGES_MOCK_TEST + "?subject=" + subject
    })
  }
})